/**
 * karin   2017.04.25
 * 空白页面
 */
import React, { Component } from 'react'
import { connect } from 'react-redux'

// 加载组件
import { Modal, Button, WhiteSpace, WingBlank } from 'antd-mobile'
import Loading from '../../components/Loading'
import jsApi from '../../utils/cx580.jsApi'
import appVersion from "../../utils/appVersion";

/**
 * 组件
 */

class NewAppUrl extends Component {
	constructor(props) {
		super(props);
		this.state = {};
		this.carnumber = decodeURIComponent(this.props.params.carnumber);
		this.carId = this.props.params.carId;
		this.target = this.props.params.target;

	}
	/**
	 * 生命周期
	 */
	componentDidMount() {
		//	Toast.loading('请稍等', 1);
		// 跳到违章详情页面
		//alert('app -2 , target = ' + this.target + ' , carId = ' + this.carId + ' , ' + this.carnumber);
		setTimeout(() => {
			let jsApiData={
                'commandId': '',
                'command': 'jump',
                'data': {
                    'target': this.target,
                    'carId': this.carId,
                    'carNumber': this.carnumber,
                    'tabName': '违章'
                }/*封装需要跳转的数据，地址、参数等*/
            };
			//6.33以上使用3.0SDK,传参方式改变
			if(appVersion.getMainVersionByCount()>=6.33){
                jsApiData={
                    'commandId': '',
                    'command': 'jump',
                    'data': {
                        'jumpData':{
                            'target': this.target,
                            'carId': this.carId,
                            'carNumber': this.carnumber,
                            'tabName': '违章'
                        }
                    }/*封装需要跳转的数据，地址、参数等*/
                };
			}
                // 违章
                jsApi.call(jsApiData);
		}, 500);
		// 延迟出现弹窗
		setTimeout(() => {
			Modal.alert('返回办理年检', '', [
				{
					text: '确定',
					onPress: () => {
						window.cx580.jsApi.call(
							{
								"commandId": "",
								"command": "close"
							});
					},
					style: { color: '#108ee9' },
				},
			])
		}, 1000);


	}
	/**
	 * 事件
	 */


	/**
	 * 组件
	 */
	render() {

		return (
			<Loading></Loading>
		)
	}
}

NewAppUrl.contextTypes = {
	router: React.PropTypes.object.isRequired
}

NewAppUrl.defaultProps = {

};

export default connect()(NewAppUrl)